#-*- coding:UTF-8 -*-
__author__ = 'Frank Yang <frankyang418@gmail.com>'
__date__ = "13-5-16 上午10:41"
__doc__ = u""

from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from tornado.options import options

conn_str = "mysql://%s:%s@%s/%s?charset=utf8" % (options.db_user, options.db_pwd, options.db_host, options.db_name)
engine = create_engine(conn_str, convert_unicode=True, echo=False)
db_session = scoped_session(sessionmaker(bind=engine))
Base = declarative_base()
Base.query = db_session.query_property()